package com.syxp.pda.service.detail.impl;

import java.util.List;

import com.syxp.pda.core.util.ArraysBuilder;
import com.syxp.pda.dao.base.DefineIDZoneDao;
import com.syxp.pda.dao.detail.CheckPlanDetailDao;
import com.syxp.pda.dao.standard.DeviceCheckStandardDao;
import com.syxp.pda.entity.base.DefineIDZone;
import com.syxp.pda.service.detail.PointsAnalysisService;

public class PointsAnalysisServiceImpl implements PointsAnalysisService {

	private DefineIDZoneDao defineIDZoneDao;

	private DeviceCheckStandardDao deviceCheckStandardDao;

	private CheckPlanDetailDao checkPlanDetailDao;

	public DefineIDZoneDao getDefineIDZoneDao() {
		return defineIDZoneDao;
	}

	public void setDefineIDZoneDao(DefineIDZoneDao defineIDZoneDao) {
		this.defineIDZoneDao = defineIDZoneDao;
	}

	public DeviceCheckStandardDao getDeviceCheckStandardDao() {
		return deviceCheckStandardDao;
	}

	public void setDeviceCheckStandardDao(
			DeviceCheckStandardDao deviceCheckStandardDao) {
		this.deviceCheckStandardDao = deviceCheckStandardDao;
	}

	public CheckPlanDetailDao getCheckPlanDetailDao() {
		return checkPlanDetailDao; 
	}

	public void setCheckPlanDetailDao(CheckPlanDetailDao checkPlanDetailDao) {
		this.checkPlanDetailDao = checkPlanDetailDao;
	}

	@Override
	public List<DefineIDZone> loadZoneDevice() {
		List<DefineIDZone> zones = defineIDZoneDao.getAll();
		for (DefineIDZone zone : zones) {
			zone.setDevices(ArraysBuilder.buildSet(zone.getDevices()));
		}
		return zones;
	}

	@Override
	public List<Object[]> loadCHKItem(Integer deviceIDs[]) {
		return deviceCheckStandardDao.getByDeviceID(deviceIDs);
	}

	public List<Object[]> analysis(Integer deviceIDs[], String chkItem,
			String startDate, String endDate,String precision) {
		return checkPlanDetailDao.getPointsAnalysis(deviceIDs, chkItem, startDate, endDate,precision) ;
	}
}
